<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>9、运用定时器,让 div 一秒后移动 </title>
  <style>
    div {
      width: 20px;
      height: 20px;
      position: absolute;
      background-color: red;
    }
  </style>
</head>

<body>
  <div id="box"></div>
  <script>
    var box1 = document.getElementById('box')
    var flag = 1000;
    function myfunc2() {
      box1.style.left = flag + 'px';
      flag++
    }
    setInterval(myfunc2, 1000)

  </script>
</body>

</html>